import java.util.Arrays;

import org.apache.commons.lang.StringUtils;


public class StringUtil
{
	public static void main(String[] args)
	{
		String winFilePath = "C:\\Temp\\my file.txt";
		String unixFilePath = "/temp/file.txt";
		String testPath = "_some_filename.txt";
		
		System.out.println("win file path: " + winFilePath + ", filename: " + getFilename(winFilePath));
		System.out.println("unix file path: " + unixFilePath + ", filename: " + getFilename(unixFilePath));
		System.out.println("test path: " + testPath + ", filename: " + getFilename(testPath));
		
		testStringUtils();
	}

	public static String getFilename(String fullpath){
		//this method tries to work with windows-style filename, and linux-style filename
		//with the requirement that \ or / is not a legal character on a filename.
		if (fullpath==null)return null;		
		String[] names= fullpath.split("\\\\|/");
		return names[names.length-1];
	}
	
	public static void testStringUtils() {
		
		String source = "hlee@vitechinc.com,   heonkoo.lee@gmail.com,";
		String[] result = StringUtils.split(source, ", ");
		
		System.out.println("source: " + source);
		for (int i=0; i < result.length; i++)
			System.out.println("result[" + i + "]:" + result[i] + ":");
	}
	
}
